
//获取应用实例
const app = getApp()
const api = require('../../utils/api.js');
const util = require('../../utils/util.js');
Page({
	data: {
		order:{},
	},
	onLoad: function(options) {
		this.getOrderInfo(options.id);
	},
	getOrderInfo:function(id){
		let _this = this;
		api.orderInfo({
			data: {
				id:id
			},
			success: function(res) {
				if(res.data.code == 0) {
					
					if(res.data.obj.course.enterStartTime != null){
						res.data.obj.course.enterStartTime = util.formatMinute(new Date(res.data.obj.course.enterStartTime));
					}else{
						if(res.data.obj.courseTime.startTime != null) {
							res.data.obj.course.enterStartTime = util.formatMinute(new Date(res.data.obj.courseTime.startTime));
						}
					}
					_this.setData({
						order:res.data.obj,
					})
				}
			},
		});
	},
	backMoney(){
		let _this = this;
		api.drawBack({
			data: {
				id:this.data.order.id
			},
			success: function(res) {
				if(res.data.code == 0) {
					wx.showModal({
						 title: '成功',
						 content: "退款后等待30个工作日,以遛点的形式退回到您的遛点账户中,请在[我的] - [遛点]下查看。",
						 showCancel:false,
						 success: function(res) {
						  
						 }
					});  
				}else{
					wx.showModal({
						 title: '提示',
						 content: "退款失败",
						 showCancel:false,
						 success: function(res) {
						  
						 }
					});  
				}
			},
		});
	},
})